#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> a;
int main() {
    int w, n;
    cin >> w >> n;
    while(n--) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end());
    int ans = 0;
    int l = 0, r = a.size() - 1;
    while(l <= r) {
        if(a[l] + a[r] <= w) {
            ans++;
            l++;
            r--;
        }else {
            r--;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}